package com.legal.utils;

import org.springframework.beans.BeanUtils;

public class BeanUtil extends BeanUtils {
    /**
     * 拷贝对象
     * @param source 源对象
     * @param clazz 目标对象类
     * @param <T> 目标对象类型
     * @return
     */
    public static <T> T copy(Object source, Class<T> clazz) {
        T target = null;
        try {
            target = clazz.newInstance();
        } catch (Exception e) {
            e.printStackTrace();
        }
        BeanUtils.copyProperties(source, target);
        return target;
    }
}
